package com.daocao.ds.api;



import java.util.concurrent.TimeUnit;

import com.daocao.ds.constant.Const;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/5/14.
 */

public class Api {

    public static final ApiService api_service;
    public static final OkHttpClient okhttpClient;
    static {
        okhttpClient = new OkHttpClient.Builder().
                connectTimeout(10 * 1000, TimeUnit.SECONDS).
                writeTimeout(10 * 1000, TimeUnit.SECONDS).
                readTimeout(10 * 1000, TimeUnit.SECONDS).
                addInterceptor(new TokenInterceptor()).
//                addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).
                build();

        Retrofit retrofit = new Retrofit.Builder()
                .client(okhttpClient)
                .baseUrl(Const.SERVER_API_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        api_service = retrofit.create(ApiService.class);
    }



}
